package com.youzhi.backend.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.youzhi.backend.dto.Page;
import com.youzhi.backend.dto.Result;
import com.youzhi.backend.entity.Demo;
import com.youzhi.backend.service.IDemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 游戏目录表 前端控制器
 * </p>
 *
 * @author xumeng
 * @since 2022-11-16
 */
@RestController
@RequestMapping("/demo")
// tags：你可以当作是这个组的名字。
@Api(tags = "Demo示例")
public class DemoController {


    @Autowired
    private IDemoService demoService;


    @ApiOperation(value = "demo保存", notes = "接口示例")
    @PostMapping("/save")
    public Result save(@RequestBody Demo demo) {
        demoService.save(demo);
        return Result.ok();
    }



    @RequiresUser
    @RequiresRoles("admin")
//    @RequiresPermissions("demo:read")
    @ApiOperation(value = "分页查询demo", notes = "接口示例")
    @PostMapping("/page")
    public Result<IPage<Demo>> selectPage(@RequestBody Page page) {
        return Result.ok(demoService.selectPage(page));
    }



}

